//封装对于用于数据的本地持久化存储
const KEY = 'heimapc'

const setUserInfo = function (userInfo){
    let userinfoStr
    try{
        userinfoStr = JSON.stringify(userInfo)
    } catch(error){
        console.error(error)
        userinfoStr = ''
    }
    window.localStorage.setItem(KEY,userinfoStr)
}


const getUserToken = function(){
    let userinfo
    try {
        userinfo = JSON.parse(window.localStorage.getItem(KEY))
    } catch (error) {
        console.error(error)
        userinfo = {}
    }
    return userinfo
}

const delUserToken = function(){
    window.localStorage.removeItem("KEY")
}

export {
    setUserInfo,
    getUserToken,
    delUserToken
}